﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProdeFrontEnd.Clases;
using ProdeFrontEnd.ServiceReferenceProde;
using System.Data;

namespace ProdeFrontEnd.Pags
{
    public partial class AdminConf : System.Web.UI.Page
    {
        private ServiceProde serviceProde;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null) //Se tiene que salir
            {
                Response.Redirect("NewUser.aspx");
            }
            serviceProde = ServiceProde.getInstanceServiceProde();
            loadTournaments();
        }

        private void loadTournaments()
        {
            Tournament[] tournaments = serviceProde.prodeClient.getTournaments();

            DataTable dataTable = new DataTable();
            dataTable.Columns.AddRange(new DataColumn[4] {
                                new DataColumn("tournament",typeof(string)),
                                new DataColumn("start",typeof(string)),
                                new DataColumn("finish",typeof(string)),
                                new DataColumn("idTournament",typeof(int)) });

            foreach (Tournament tournament in tournaments)
            {
                dataTable.Rows.Add(tournament.name, tournament.start.ToString("d"), tournament.end.ToString("d"), tournament.id);
            }

            GridView1.DataSource = dataTable;
            GridView1.DataBind();
        }

        protected void DeleteCustomer(object sender, EventArgs e)
        {

        }

        protected void AddNewCustomer(object sender, EventArgs e)
        {

        }
    }
}